import { GenerateDataType } from "@/interface";
import { createStore } from "vuex";

export default createStore<GenerateDataType>({
  state: {
    cachePageList: [],
    currentPath: ""
  },
  mutations: {
    SET_CACHEPAGE_LIST: (state, data: string) => {
      state.cachePageList.push(data);
    },
    CLEAR_CACHEPAGE_LIST: state => {
      state.cachePageList = [];
    },
    INIT_CACHEPAGE_LIST: (state, data: Array<string>) => {
      state.cachePageList = data;
    },
    CHANGE_CURRENTPATH: (state, data: string) => {
      state.currentPath = data;
    }
  },
  actions: {
    SET_CACHEPAGE_LISTACTION: ({ commit }, data) => {
      commit("SET_CACHEPAGE_LIST", data);
    },
    CLEAR_CACHEPAGE_LISTACTION: ({ commit }) => {
      commit("CLEAR_CACHEPAGE_LIST");
    },
    INIT_CACHEPAGE_LISTACTION: ({ commit }, data) => {
      commit("INIT_CACHEPAGE_LIST", data);
    },
    CHANGE_CURRENTPATH_ACTION: ({ commit }, data) => {
      commit("CHANGE_CURRENTPATH", data);
    }
  },
  modules: {}
});
